﻿#region Copyright(c) 2006 ZO, All right reserved.
// -----------------------------------------------------------------------------
// Copyright(c) 2006 ZO, All right reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   1.  Redistribution of source code must retain the above copyright notice,
//       this list of conditions and the following disclaimer.
//   2.  Redistribution in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//   3.  The name of the author may not be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
#endregion


#region Using directives

using System;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Windows.Forms;
using ZO.SmartCore.Interop.Windows;

#endregion

namespace ZO.SmartCore.Windows.Forms
{
    /// <summary>
    /// Represents a window or dialog box that makes up an application's user interface.
    /// </summary>
	[ToolboxBitmap(typeof(Form))]
    [ToolboxItem(false)]
	public class SmartForm : Form
    {

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="SmartForm"/> class.
        /// </summary>
        public SmartForm()
            : this(false)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SmartForm"/> class.
        /// </summary>
        /// <param name="dropShadow">if set to <see langword="true"/> [dropshadow].</param>
        public SmartForm(bool dropShadow)
            : base()
        {
            this.InitializeComponent();
            this.DropShadow = dropShadow;
        }
        #endregion

        #region Destructor
        /// <summary>
        /// Releases unmanaged resources and performs other cleanup operations before the
        /// <see cref="T:SmartCore.Windows.Forms.SmartForm"/> is reclaimed by garbage collection.
        /// </summary>
        ~SmartForm()
        {
            this.Dispose(false);
        }
        #endregion

        #region Fields

        private bool _DropShadow;

        #endregion

        #region Events
  
        #endregion

        #region Operators

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a value indicating whether form will display drop shadow.
        /// </summary>
        /// <value>
        /// 	<see langword="true"/> if [drop shadow]; otherwise, <see langword="false"/>.
        /// </value>
        [Description("Gets or sets a value indicating whether form will display drop shadow.")]
        public bool DropShadow
        {
            get
            {
                return _DropShadow;
            }
            set
            {
                _DropShadow = value;
            }
        }

        #endregion

        #region Methods
        /// <summary>
        /// Encapsulates the information needed when creating a control.
        /// </summary>
        /// <value>The create params.</value>
        protected override CreateParams CreateParams
        {
            [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
            get
            {
                CreateParams parameters = base.CreateParams;

                if (DropShadow & OSInfo.IsWindowsXPOrAbove)
                {
                    parameters.ClassStyle |= (int)ClassStyles.DropShadow;
                }

                return parameters;
            }
        }

        /// <summary>
        /// Initializes the component.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // BaseForm
            // 
            this.ClientSize = new Size(292, 266);
            this.Name = "SmartForm";
            this.ResumeLayout(false);

        }

        /// <summary>
        /// Disposes of the resources (other than memory) used by the <see cref="T:System.Windows.Forms.Form"></see>.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                try
                {
                    //If disposing equals true, dispose all managed 
                    // and unmanaged resources.
                    if (disposing)
                    {
                        this.DisposeManagedResources();
                        this.DisposeUnmanagedResources();
                    }

                    else
                    {
                        this.DisposeUnmanagedResources();
                    }

                }
                catch
                {
                    throw;
                }
                base.Dispose(disposing);
            }
        }


        /// <summary>
        /// Override This Method To Dispose Unmanaged Resources.
        /// </summary>
        protected virtual void DisposeManagedResources() { }

        /// <summary>
        /// Override This Method To Dispose Managed Resources.
        /// </summary>
        protected virtual void DisposeUnmanagedResources() { }


        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Closed"></see> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnClosed(EventArgs e)
        {
            this.Dispose();
            base.OnClosed(e);
        }
        #endregion





     
    }
}
